Repository navigation
[2.0] feat(data-insights): add the DataInsightsExtension hook (backport of #33079's hook) - #37815
Conversation
Backports the extension hook from #33079 to 2.0, without the completeness evidence that PR also adds: DataInsightsExtension (a ServiceLoader SPI with run-scoped sessions), DataInsightsExtensions (opens every provider for a run, closes them on failure) and the DataAssetsWorkflow calls (beforeBatch, enrich on each snapshot document, complete after a successful run). Unlike main, the 2.0 hook writes no diRunId/diCapturedAt stamp of its own: 2.0's index template has no mapping for them, so they would surface as new Data Insights fields on every document. With no provider registered, a run behaves as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically. Maintainers can bypass this check by adding the |
| continue; | ||
| } | ||
|
|
||
| extensions.beforeBatch(batch.getData()); |
There was a problem hiding this comment.
💡 Edge Case: Cancellation in beforeBatch skips the per-source stats update
extensions.beforeBatch(...) (line 316) calls requireActive(), which throws CancellationException if stop() ran between batches or if the thread was left interrupted after the InterruptedException branch at line 372, which only breaks out of the current source. The inner try only catches SearchIndexException and InterruptedException, so the exception goes straight out of processSource. That skips the trailing drainAndFlush/updateWorkflowStats/mergeEnricherStepStats block (lines 381-386), and process() swallows the exception at line 247. Before this change, a stop inside a source still ended the loop normally and recorded that source's stats. With this change, they are lost on cancellation even when no extension is registered, since requireActive() runs no matter how many sessions exist. Fix: catch CancellationException inside the batch loop (mark it stopped and break), or check stopped instead of calling requireActive() before the batch.
Treat cancellation from the extension hook as a normal stop so the per-source finalisation still runs.:
} catch (CancellationException ex) {
stopped = true;
break;
} catch (InterruptedException ex) {
Thread.currentThread().interrupt();
break;
}
Was this helpful? React with 👍 / 👎
Code Review 👍 Approved with suggestions 🟡 Medium risk 0 closed / 1 findingsThe new ServiceLoader hook lets providers alter indexed Data Insights snapshots, so faulty enrichment could write incorrect fields or disrupt runs. Adds the
💡 Edge Case: Cancellation in beforeBatch skips the per-source stats update📄 openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/DataAssetsWorkflow.java:316 📄 openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/DataAssetsWorkflow.java:365-379 📄 openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/DataAssetsWorkflow.java:247-249 📄 openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/insights/workflows/dataAssets/DataInsightsExtensions.java:58-61
Treat cancellation from the extension hook as a normal stop so the per-source finalisation still runs.🤖 Prompt for agentsVerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
Describe your changes:
Backport of the Data Insights extension hook from #33079 to
2.0. This carries existingmaincode to2.0, so no separate issue is linked.On
main,DataAssetsWorkflowopens everyDataInsightsExtensionthatServiceLoaderfinds for a Data Insights run, and each one can add fields to the snapshot documents.2.0has no such hook, so a distribution built on2.0cannot add a field to the Data Insights snapshot without patching the workflow. This PR adds the hook and nothing else from #33079:DataInsightsExtension: the SPI, the same as onmainexcept that2.0'sEntityInterfaceis not generic.DataInsightsExtensions: opens every provider for one run and closes them on a failed start or at the end.DataAssetsWorkflow: callsbeforeBatchbefore each batch is enriched,enrichon each snapshot document, andcompleteafter a run that neither stopped nor failed. The calls sit wheremainhas them.Everything else in #33079 is left out: the completeness evidence, the index-template fields, the search-client changes and the failure-reporting changes. So is
main'sdiRunId/diCapturedAtstamp on every document.2.0's index template has no mapping for those two fields, so dynamic mapping would add them to every Data Insights document as new fields.OpenMetadata registers no provider, so an OSS run does the same work as before.
Type of change:
High-level design:
N/A, small change: one SPI, its run-scoped composite, and the workflow calls
mainalready has.Tests:
Use cases covered
Unit tests
DataInsightsExtensionsTest, frommain. One case changes: on2.0it asserts that the composite writes nothing of its own to a snapshot, only what the sessions add.2.0@ab670ac85a6,mvn install -pl openmetadata-service -am -Dtest='DataInsightsExtensionsTest,DataAssetsWorkflowConcurrencyTest'ran 7 tests with 0 failures.Backend integration tests
DataInsightsEnricherBehaviorIT,EnricherBulkVsHistoryPathEquivalenceIT) run the workflow and were not run locally; CI runs them.Ingestion integration tests
Playwright (UI) tests
Manual testing performed
2.0instance with a provider registered.UI screen recording / screenshots:
Not applicable.
Checklist:
Fixes <issue-number>: <short explanation>: a backport of feat(data-insights): capture completeness evidence and extend run lifecycle #33079, no separate issue.Fixes #<issue-number>above: same reason.🤖 Generated with Claude Code